package com.ruoyi.framework.config;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.service.ISysConfigService;

public class ConfigKeyUtil {

    public static String getString(String key) {
        return SpringUtils.getBean(ISysConfigService.class).selectConfigByKey(key);
    }

    public static Boolean getBoolean(String key) {
        return "true".equals(getString(key));
    }

    public static Integer getInteger(String key) {
        String value = getString(key);
        if (StringUtils.isEmpty(value)) {
            return null;
        } else {
            return Integer.valueOf(value);
        }
    }

    public static int DEVICE_APPLY_PROBATION_DAY() {
        Integer applyDay = getInteger("sys.vip.proday");
        if (StringUtils.isNull(applyDay)) return 0;
        return applyDay.intValue();
    }

    public static String ERROR_CODE_VMLINK_401() {
        return ConfigKeyUtil.getString("sys.noAuth.message");
    }
}
